<?php echo $this->html->loadCSS("content/gmode_admin/css/style_fcbk.css");?>
<?php echo $this->html->loadJS("content/gmode_admin/js/jquery.fcbkcomplete.min.js");?>

<script type="text/javascript">
	$(document).ready(function(){
		
		$("#size").fcbkcomplete({
            addontab: true,                   
            height: 2                 
        });
        
		//$.facebooklist('#size', '#size', 10, {userfilter:1,casesensetive:0});
		                		
	});
</script>

<div class="container_8 clearfix">                
	<!-- Main Section -->
	<section class="main-section grid_8">
		<!-- Forms Section -->
		<div class="main-content grid_8 alpha">
			<header>
				<ul class="action-buttons clearfix fr">
					<li><a href="<?php echo $this->url->action("index")?>" class="modalInput" rel="#simpledialog">Danh mục sản phẩm</a></li>
				</ul>
				<h2>Cập nhật thông tin sản phẩm</h2>
			</header>
			<section class="clearfix">
				<?php echo $this->html->beginForm("edit",array('class'=>"form"))?>
				<?php echo $this->html->enableClientSideValidation();?>
					<?php $this->html->hiddenFor('id');
					?>
					<div class="clearfix">
						<?php $this->html->labelFor("categoryID");?>
						<select name="categoryID">
							<?php foreach ($this->arrCategories as $category){
							if ($category['parentID'] == 0)
							{
							?>
								<option <?php if ($this->model->categoryID == $category['id']) echo 'selected="selected"';?> value="<?php echo $category['id']?>" style="font-weight: bold;"><?php echo $category['name']?></option>
							<?php 
							}
							else 
							{
							?>
								<option <?php if ($this->model->categoryID == $category['id']) echo 'selected="selected"';?> value="<?php echo $category['id']?>">.....<?php echo $category['name']?></option>
							<?php 
							}
							}
							?>
						</select>
					</div>
					<div class="clearfix">
						<?php $this->html->labelFor("name") ?>
						<?php $this->html->textboxFor("name") ?>
						<?php $this->html->validationMessageFor("name")?>
					</div>
					<div class="clearfix">
						<?php $this->html->labelFor("price") ?>
						<?php $this->html->textboxFor("price") ?>
						<?php $this->html->validationMessageFor("price")?>
					</div>
					<div class="clearfix">
						<?php $this->html->labelFor("unit") ?>
						<?php $this->html->textboxFor("unit") ?>
						<?php $this->html->validationMessageFor("unit")?>
					</div>
					<div class="clearfix">
						<?php $this->html->labelFor("brandID") ?>
						<?php $this->html->selectFor("brandID",$this->arrBrands,'id','name') ?>
					</div>
					<div class="clearfix">
						<?php $this->html->labelFor("materialID") ?>
						<?php $this->html->selectFor("materialID",$this->arrMaterials,'id','name') ?>
					</div>
					<div class="clearfix">
						<?php $this->html->labelFor("color") ?>
						<?php $this->html->textboxFor("color") ?>
						<?php $this->html->validationMessageFor("color")?>
					</div>
					<div class="clearfix">
						<?php $this->html->labelFor("size") ?>
						<select id="size" name="size">
							<?php echo $this->options;?>
						</select>
					</div>
					<div class="clearfix">
      					<?php $this->html->labelFor("image") ?>
      					<?php $this->html->textboxFor("image") ?>
      					<button class="button button-gray" type="button" onclick="openGallery('image');">Duyệt</button>
     					<?php $this->html->validationMessageFor("image")?>
     				</div>
					<div class="clearfix">
					     <?php $this->html->labelFor("subimages") ?>
					     <input type="text" name="imagesselect" id="imageselect" />
					     <button class="button button-gray" type="button" onclick="openGallery('imageselect');">Duyệt</button>
					     <button class="button button-gray" type="button" onclick="selectImage();">Chọn</button>
				    </div>
     				<div class="clearfix">
				    	<label>Danh sách ảnh phụ</label>
				     	<?php $this->html->textareaFor("subimages", array("style" => "width: 400px; height: 100px")) ?>
				     	<p>Mỗi ảnh một dòng, cuối mỗi dòng có dấu "," (dòng cuối cùng không có)</p>
				    	<?php $this->html->validationMessageFor("subimages")?>
				    </div>
				    <div class="clearfix">
				    	<?php $this->html->labelFor("highlight") ?>
				    	<?php $this->html->checkboxFor("highlight") ?>
				    </div>
				    <div class="clearfix">
				    	<label>Mô tả sản phẩm</label>
				     	<?php $this->html->textareaFor("description", array("style" => "width: 400px; height: 100px")) ?>
				    </div>
					<div class="action clearfix">
						<button class="button button-gray" type="submit"><span class="accept"></span>Cập nhật</button>
						<button class="button button-gray" type="reset">Làm lại</button>
					</div>
				<?php echo $this->html->endForm();?>
			</section>
		</div>
		<!-- End Forms Section -->
		<div class="clear"></div>
	</section>
    <!-- Main Section End -->
</div>
<script type="text/javascript" src="<?php echo $this->url->content("library/tiny_mce/plugins/imagemanager/js/mcimagemanager.js") ?>"></script>
<script type="text/javascript">
 function openGallery(ele){
  mcImageManager.open('edit', ele);
 }
 function selectImage(){
  if($("#imageselect").val() == "")
  {
   alert("Bạn hãy điền đường dẫn ảnh !");
   return false;
  }
  if($("#subimages").val() == "")
   $("#subimages").val($("#imageselect").val());
  else
   $("#subimages").val($("#subimages").val() + ",\n" + $("#imageselect").val());
 }
</script>
<script type="text/javascript" src="<?php echo $this->url->content("library/tiny_mce/tiny_mce.js") ?>"></script>
<script type="text/javascript">
 $(document).ready(function(){
 	//TinyMCE
    // O2k7 skin (silver)
    tinyMCE.init({
    	// General options
        mode: "exact",
        elements: "description",
        theme: "advanced",
        skin: "cirkuit",
        skin_variant: "silver",
        plugins: "imagemanager,filemanager,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",

        // Theme options
        theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,

        relative_urls : false,
    
        language: "en",

        height: "400",

        width: "100%"
     });
 });
</script>